package com.intellagric.controller.module.loganalyse;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.pojo.LogAnalyzeJob;
import com.intellagric.service.module.loganalyse.LogAnalyseJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

/**
 * @Auther: zhy
 * @Date: 2019/5/11
 * @Description: 日志分析任务管理
 */
@Controller
public class LogAnalyseJobController {

    @Autowired
    private LogAnalyseJobService logAnalyseJobService;

    /**
     * 添加日志分析任务信息
     * @Param logAnalyzeJob
     * @return ResponseMessage
     */
    @RequestMapping("/log/analysejob/add")
    @ResponseBody
    public ResponseMessage add(LogAnalyzeJob logAnalyzeJob) {
        logAnalyzeJob.setCreatedate(new Date());
        logAnalyzeJob.setUpdatadate(new Date());
        return logAnalyseJobService.addLogAnalyzeJob(logAnalyzeJob);
    }


    /**
     * 删除日志分析任务信息
     * @Param id
     * @return ResponseMessage
     */
    @RequestMapping("/log/analysejob/delete")
    @ResponseBody
    public ResponseMessage delete(int id,String indexName) {
        return logAnalyseJobService.deleteLogAnalyzeJob(id,indexName);
    }

    /**
     * 修改日志分析任务信息
     * @Param logAnalyzeJob
     * @return ResponseMessage
     */
    @RequestMapping("/log/analysejob/edit")
    @ResponseBody
    public ResponseMessage edit(LogAnalyzeJob logAnalyzeJob) {
        return logAnalyseJobService.editLogAnalyzeJob(logAnalyzeJob);
    }

    /**
     * 根据id,indexName查询日志分析任务信息
     * @return LogAnalyzeJob
     */
    @RequestMapping("/log/analysejob/detail")
    @ResponseBody
    public LogAnalyzeJob get(int id,String indexName) {
        return logAnalyseJobService.queryLogAnalyzeJobById(id,indexName);
    }

    /**
     * 查询日志分析任务信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/log/analysejob/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return logAnalyseJobService.queryLogAnalyzeJobList();
    }

    /**
     * 查询日志分析任务信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/log/analysejob/query")
    @ResponseBody
    public LayuiDataGridResult getListByBusinessNumber(int business,String datetime) {
        return logAnalyseJobService.queryLogAnalyzeJobByBusinessId(business,datetime);
    }

    /**
     * 分页查询日志分析任务信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/log/analysejob/page")
    @ResponseBody
    public LayuiDataGridResult getPage() {
        return logAnalyseJobService.queryLogAnalyzeJobList();
    }


}
